-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-91524: Speed up the regular expression substitution #91525
Conversation
Functions re.sub() and re.subn() and corresponding re.Pattern methods are now 2-3 times faster for replacement strings containing group references.
When you're done making the requested changes, leave the comment: |
If use There are two data contracts that crossing functions:
Such data contracts increase the difficulty of code maintenance. If use typedef struct {
PyObject_VAR_HEAD
struct {
int type; // literal or group
PyObject *item;
} items[0];
} TemplateObject; In the current PR, adjacent groups also waste space. |
…thon into re-compile-template
I do not think so. The benefit of I may try to experiment with |
Thank you for review. The conditions of my sight make my to easily miss some details. I have made the requested changes; please review again. |
Thanks for making the requested changes! @gpshead: please review the changes made to this pull request. |
Please do not do this. Your help compensates my disadvantage. |
@animalize - While it is great you are concerned for others health, it comes across poorly to say things in an "ultimatum" style such as a "threat" to stop working with someone because they've implied they may have a health concern. This is not kind. In many cultures (including Python's) that conduct is seen as discrimination. It limits others opportunities based on your own presumption of their abilities. Among committers (which @serhiy-storchaka is a long time member of) none of us expect the steering council to micromanage our lives and most of us would rightfully reject that concept if we were to try. That isn't our purpose. While asking me or the SC to treat another committer specially was presumably voiced out of genuine concern here, it can come across as a put down that belittles their work even if this is not what you intended. We trust everyone to understand their own contribution abilities and act accordingly as they see fit. Code review collaboration is a way for all of us to fill in gaps in that we all have in our work. Nobody is perfect. (I'm replying with the above in this forum so that this response is visible to the same audience as the earlier messages that led to it.) Lets ultimately stay focused on the PR here. Thanks for your reviews! |
Sorry. I don't know what to say. I tried to improve this PR locally, IMHO the data contracts and the |
I'll send a PR to serhiy-storchaka:re-compile-template later. |
@serhiy-storchaka This PR has been approved by one other core dev, but not merged for some reason. The performance improvement seems worthwhile. Is there a reason why the branch has not been updated? If needed I can help to update the branch to current main |
Thanks Serhiy & reviewers! |
Thank you Gregory for the final polishing. |
Functions re.sub() and re.subn() and corresponding re.Pattern methods
are now 2-3 times faster for replacement strings containing group references.
Closes #91524